package com.spider.spiderflowable.business.service.impl;

import com.spider.spiderflowable.business.service.INumberGenService;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @author xiong.bo
 * @version 1.0
 * @date 2025/4/20 4:12 下午
 */

@Slf4j
@Service
public class NumberGenServiceImpl implements INumberGenService {

  private static final String TIME_FORMAT = "yyyyMMddHHmmss";


  @Override
  public String generateNumberByTime(String prefix) {
    String timeCode = new SimpleDateFormat(TIME_FORMAT).format(new Date());
    // 生成 5 位随机数（范围：10000 到 99999）
    int randomNumber = new Random().nextInt(90000) + 10000;
    prefix += timeCode;
    return prefix + randomNumber;
  }


}
